package com.bauer.module.common.response;

import com.bauer.module.common.error.ErrorCode;

import java.io.Serializable;

/**
 * @Author ：rui.wei
 * @Date ：Created in 17:21 2019/4/10
 * @Description：
 */
public class TsResponse<T> implements Serializable {

    private String code;

    private String message;

    private T result;

    public static final TsResponse SUCCESS = new TsResponse<>(ErrorCode.SUCCESS, null);

    public static final TsResponse PARAM_ERROR = new TsResponse<>(ErrorCode.PARAM_ERROR, null);

    public TsResponse() {
    }

    public TsResponse(ErrorCode errorCode, T result) {
        this.message = errorCode.getMessage();
        this.code = errorCode.getCode();
        this.result = result;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public boolean isSuccess() {
        if (ErrorCode.SUCCESS.getCode().equals(code)) {
            return true;
        }
        return false;
    }
}
